home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pas_all.zip / TI134.ASC < prev    next >
Text File  |  1992-08-12  |  2KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.   PRODUCT : TURBO PASCAL                               NUMBER : 134
  10.   VERSION : 3.0xx
  11.        OS : PC-DOS, MS-DOS
  12.      DATE : April 2, 1986                                PAGE : 1/2
  13.     TITLE : RANDOM NUMBER SEED LOCATIONS
  14.  
  15.  
  16.  
  17.  
  18.   Turbo Pascal maintains a four byte random number seed. There is
  19.   a Randomize procedure to give that seed a random value which the
  20.   function, Random, then uses to generate random values within a
  21.   specified range.
  22.  
  23.   Random :  r := seed;
  24.  
  25.   The function Random(value) calls the following routine:
  26.  
  27.   function Random(N_Max): real;
  28.   var c1, c2, r : real;
  29.   begin
  30.     c1 := exp(32 * ln(2));
  31.     c2 := exp(16 * ln(2));
  32.     r  := (r * 129 * $361962E9) mod c1;
  33.     Random := r div c2 mod N_Max;
  34.   end;
  35.  
  36.   The following table gives the random number seed address for most
  37.   Turbo Pascal implementations:
  38.  
  39.   Random Number Seed Locations
  40.  
  41.     IBM TURBO.COM        01FC
  42.     IBM TURBO-87.COM  01FE
  43.     IBM TURBOBCD.COM  0200
  44.     Generic TURBO.COM    01DA
  45.  
  46.   The seed may be declared as:
  47.  
  48.     Var RandomSeed: Array [0..3] Of Byte Absolute DSeg:$01FC;
  49.  
  50.   or:
  51.  
  52.     Var RandomSeed: Array [0..1] Of Integer Absolute DSeg:$01FC;
  53.  
  54.   By replacing the value in the address, you can seed the random
  55.   number generator in any way you like: read it from a file; read a
  56.   number from the user; ask for the user to hit a key, and count
  57.   until he does; get the system time; or, assign a constant va
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.   PRODUCT : TURBO PASCAL                               NUMBER : 134
  76.   VERSION : 3.0xx
  77.        OS : PC-DOS, MS-DOS
  78.      DATE : April 2, 1986                                PAGE : 2/2
  79.     TITLE : RANDOM NUMBER SEED LOCATIONS
  80.  
  81.  
  82.  
  83.  
  84.   DISCLAIMER: You have the right to use this technical information
  85.   subject to the terms of the No-Nonsense License Statement that
  86.   you received with the Borland product to which this information
  87.   pertains.
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.